package net.oschina.app.viewpagerfragment.MyFragment;

import android.support.v4.app.Fragment;

import net.oschina.app.util.UIUtils;

/**
 * Created by foty on 2017/4/2.
 * fragment 的制作工厂
 */

public class FragmentFactory {
    // 根据不同position返回Fragment
    public static Fragment createFragments(int layout, int position) {

        String[] fragments = UIUtils.getStrings(layout);
        String clssStr = fragments[position];
        try {
            Class<?> clss = Class.forName(clssStr);
            BaseItemFragment fragment = (BaseItemFragment) clss.newInstance();
            return fragment;
        } catch (Exception e) {
            e.printStackTrace();
        }
        BaseItemFragment fragment = null;
        return fragment;
    }
}
